package com.qdxwx.data.service.company;

import com.qdxwx.common.page.PageRequest;
import com.qdxwx.data.mapper.company.CompanyAccountDetailMapper;
import com.qdxwx.models.company.CompanyAccountDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Service
public class CompanyAccountDetailServiceImpl implements CompanyAccountDetailService {

    @Autowired
    private CompanyAccountDetailMapper companyAccountDetailMapper;

    @Override
    public int insert(CompanyAccountDetail detail) {
        detail.setCreateTime(LocalDateTime.now());
        return companyAccountDetailMapper.insert(detail);
    }

    @Override
    public int update(CompanyAccountDetail detail) {
        if(detail.getId() < 1) return 0;
        detail.setCreateTime(LocalDateTime.now());
        return companyAccountDetailMapper.update(detail);
    }

    @Override
    public int deleteById(int id) {
        if(id < 1) return 0;
        return companyAccountDetailMapper.deleteById(id);
    }

    @Override
    public CompanyAccountDetail getById(int id) {
        if(id < 1) return null;
        return companyAccountDetailMapper.selectById(id);
    }

    @Override
    public CompanyAccountDetail getByOrderId(int orderId) {
        if(orderId < 1) return null;
        return companyAccountDetailMapper.selectByOrderId(orderId);
    }

    @Override
    public List<CompanyAccountDetail> getList(CompanyAccountDetail detail, PageRequest page) {
        return companyAccountDetailMapper.selectList(detail,page);
    }

    @Override
    public long count(CompanyAccountDetail detail) {
        return companyAccountDetailMapper.selectCount(detail);
    }

}
